function response(res, code, message, data = null) {

  res.json({
    code,
    message,
    data
  });
}

module.exports = {
  success: (res, data, message = '操作成功') => response(res, 200, message, data),
  fail: (res, message, code = 100) => response(res, code, message)
};